package com.uml.umlwork.vo.course;

import com.uml.umlwork.entity.Course;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;

import java.util.Optional;

/**
 * @author Siki
 * @date 2021/1/6
 */
@ApiModel("课程信息VO")
@Getter
@Setter
@NoArgsConstructor
@ToString
public class CourseInfoVO {
    @ApiModelProperty("id")
    private Integer id;

    @ApiModelProperty("课程名称")
    private String courseName;

    @ApiModelProperty("是否开课")
    private Boolean isOpen;

    @ApiModelProperty("季度")
    private String season;

    @ApiModelProperty("年")
    private String year;

    public CourseInfoVO(Course courses){
        Optional.ofNullable(courses).ifPresent(course -> {
            this.id = course.getId();
            this.courseName = course.getCourseName();
            this.isOpen = course.getIsOpen();
            this.season = course.getSeason();
            this.year = course.getYear();
        });
    }
}
